package com.joinlabs.config;

import javax.annotation.Resource;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.joinlabs.interceptor.AdminSecurityInterceptor;
import com.joinlabs.interceptor.LoginInterceptor;

@Configuration
public class WebConfig extends WebMvcConfigurerAdapter{

	@Resource
	private AdminSecurityInterceptor adminSecurityInterceptor;
	@Resource
	private LoginInterceptor loginInterceptor;
	
	/**
	 * 添加后台拦截器
	 */
	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		
		registry.addInterceptor(adminSecurityInterceptor)
			.addPathPatterns("/admin/*") 		//拦截的路径
			.excludePathPatterns("/admin/login")      //白名单(exclude所匹配的路径不拦截)
		;
		registry.addInterceptor(loginInterceptor)
		.addPathPatterns("/friend/*","/showHomePage/*","/hotClassify/*") 		//拦截的路径
		.excludePathPatterns("/login/*","/regiest/*","/search/*","/homepage/homepage")      //白名单(exclude所匹配的路径不拦截)
		;
		
	}
	
}
